<template>
  <div
    class="loading-page"
    v-loading="loading"
    element-loading-text="系统加载中"
    element-loading-spinner="el-icon-loading"
  ></div>
</template>
<script>
// import util from "@/util";
// import { getSession, getSysCode,setSession,setSysCode,setRawSession } from "@/util/auth";
export default {
  data() {
    return {
      loading: true,
      sessionid: "",
      code: "",
    };
  },
  mounted() {
    this.code = this.getSplitKey('tokenid');
    this.$nextTick(() => {
      // 如果没有code跳转登录页
      if (this.code) {
        this.getUsertInfo();
      } else {
        this.$message.error('用户登录失败,请检查ukey！')
      }
    });
  },
  methods: {
    // 截取用url地址信息
    getSplitKey(name){
      var reg =  new RegExp("(^|&)" +name+ "=([^&]*)(&|$)");
      var r = window.location.href.split('?')[1].match(reg)
      if(r!=null) return unescape(r[2]); return null
    },
    getUsertInfo() {
      this.loading = true;
      this.$store.dispatch("user/getUserInfo", this.code)
        .then((res) => {
          this.loading = false;
          this.$router.push({ path: '/dashboard' || "/" });
        })
        .catch(() => {
          this.loading = false;
        });
    }
  }
};
</script>
<style>
.loading-page {
  height: 100vh;
}









</style>